// page/lottery/award.js
Page({
    data: {
        msg: {
            icon: "/images/icon/nodata.png",
            desc: "暂无数据"
        },
        topTabItems: ["我的奖品", "我的求助", "中奖记录"],
        currentTopItem: 0
    },

    onLoad: function (options) {
        var that = this
        if (options.currentTopItem != "undefined"){
            that.setData({
                currentTopItem: options.currentTopItem,
                prizeList: [  //我的奖品
                    { discount: "满500减50", types: "全品类通用", date: "2016.07.23", money: "50"},
                    { discount: "满500减50", types: "全品类通用", date: "2016.07.23", money: "50"},
                    { discount: "满500减50", types: "全品类通用", date: "2016.07.23", money: "50"}
                ],
                helpList: [  //我的求助
                    { avatar: "/images/index1.jpg", nickname: "李达达"},
                    { avatar: "/images/index1.jpg", nickname: "李达达"},
                    { avatar: "/images/index1.jpg", nickname: "李达达"},
                    { avatar: "/images/index1.jpg", nickname: "李达达"}
                ],
                recordList: [  //中奖记录
                    { avatar: "/images/index1.jpg", nickname: "李达达", award: "获得5元优惠劵", date: "2018.01.23 17:23:40"},
                    { avatar: "/images/index1.jpg", nickname: "李达达", award: "获得5元优惠劵", date: "2018.01.23 17:23:40"},
                    { avatar: "/images/index1.jpg", nickname: "李达达", award: "获得5元优惠劵", date: "2018.01.23 17:23:40"},
                    { avatar: "/images/index1.jpg", nickname: "李达达", award: "获得5元优惠劵", date: "2018.01.23 17:23:40"},
                ]
            })
        }
        that.message(that.data.currentTopItem)
    },
    //切换顶部标签
    switchTab: function (e) {
        var that = this
        that.setData({
            currentTopItem: e.currentTarget.dataset.idx
        })
        that.message(e.currentTarget.dataset.idx)
    },
    //swiperChange
    bindChange: function (e) {
        var that = this;
        that.setData({
            currentTopItem: e.detail.current
        })
        that.message(e.detail.current)
    },
    //无数据
    message(index){
        if (index==0){
            this.setData({
                "msg.desc": "暂无奖品！"
            })
        }else if(index==1){
            this.setData({
                "msg.desc": "还没有好友帮助过你！"
            }) 
        }else{
            this.setData({
                "msg.desc": "暂无中奖记录！"
            })        
        }
    },
    //加载更多
    loadMoreData: function () {
        wx.showLoading({
            title: '正在加载…',
        })
        var that = this
        var newData = []  //新数据
        if (that.data.currentTopItem == 0) {
            //我的奖品
        } else if (that.data.currentTopItem == 1) {
            //我的求助
        } else {
            //中奖记录
        }
        wx.hideLoading()
    }
})